﻿using Common;
using Common.EventHandler;
using Domain.Map;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using UIComponentSprite.SmallMap;

namespace UIComponentSprite.Grid
{
    /// <summary>
    /// 地图网格显示关闭按钮
    /// </summary>
    public class GridButtonSprite : UserControlledSprite
    {
        private MapGridController _mapGridSprite = new MapGridController();
        public GridButtonSprite()
        {
            this.ImgUrl = @"Images\grid\Red";
            this.ClickLeftEvent += new ClickLeftEventHandler(_mapGridSprite.ChangeShowing);
            DrawPosition.Width = 32;
            DrawPosition.Height = 32;
        }

        public override void Draw(GameTime gameTime)
        {
            if (!Showing)
                return;
            _mapGridSprite.Draw(gameTime);
            SpriteBatch.Draw(this.Image, DrawPosition, Color.White);
        }

        public override void Update(GameTime gameTime)
        {
            if (!Showing)
                return;
            LoadPic();
            DrawPosition.X = 90;
            DrawPosition.Y = GameScreen.ViewportSize.Y - DrawPosition.Height;
            LoadPic();
            ClickLeftEventListener(null);
            _mapGridSprite.Update(gameTime);
        }
    }

}
